﻿$(document).ready(function () {
    $(".hidden_new").hide();

    $("#btn_add_floor").click(function () {
        $("#Floorinfo_new").toggle("slow");
    })

    $("#btn_add_block").click(function () {
        $("#Blockinfo_new").toggle("slow");
    })

    $(".update_floor").live("click", function () {
        var ma = $(this).attr("id");
        var maTang = $("#maTang" + ma).val();
        var tenTang = $("#tenTang" + ma).val();
        var dataString = "maTang=" + maTang + "&tenTang=" + tenTang
        $.ajax({
            type: "GET",
            url: "Update_RoomFloor",
            data: dataString,
            dataType: 'html',
            success: function (data) {
                $("#notice_" + maTang).html(data).hide().fadeIn();
                setTimeout(function () {
                    $("#notice_" + maTang).fadeOut("slow", function () {
                        //$("#notice" + maLoai).remove();
                    });
                }, 2000);
            }
        });
    });


    $(".delete_floor").live("click", function () {
        var maHang = $(this).attr("id");
        var dataString = "maHang" + maHang;
        maHang = maHang.substr(1);
        $.ajax({
            type: "GET",
            url: "Delete_RoomFloor",
            data: dataString,
            dataType: 'html',
            success: function (data) {
                $("#notice_" + maHang).html(data).show();
                setTimeout(function () {
                    $("#notice_" + maHang).fadeOut("slow", function () {
                        //$("#notice" + maLoai).remove();
                    });
                }, 2000);
                location.reload();
            }
        });
    });


    $(".add_floor").live("click", function () {
        var tenTang = $("#tenTang_new").val();
        var dataString = "tenTang=" + tenTang
        $.ajax({
            type: "GET",
            url: "Add_RoomFloor",
            data: dataString,
            dataType: 'html',
            success: function (data) {
                $("#notice_new_floor").html(data).show()
                setTimeout(function () {
                    $("#notice_new_floor").fadeOut("slow", function () {
                        //$("#notice" + maLoai).remove();
                    });
                }, 2000);
                location.reload();
            }
        });
    });


    $(".update_block").live("click", function () {
        var ma = $(this).attr("id");
        var maDay = $("#maDayPhong" + ma).val();
        var tenDay = $("#tenDayPhong" + ma).val();
        var dataString = "maDayPhong=" + maDay + "&tenDayPhong=" + tenDay
        $.ajax({
            type: "GET",
            url: "Update_RoomBlock",
            data: dataString,
            dataType: 'html',
            success: function (data) {
                $("#notice_" + maDay).html(data).hide().fadeIn();
                setTimeout(function () {
                    $("#notice_" + maDay).fadeOut("slow", function () {
                        //$("#notice" + maLoai).remove();
                    });
                }, 2000);
            }
        });
    });


    $(".add_block").live("click", function () {
        var tenDay = $("#tenDayPhong_new").val();
        var dataString = "tenDay=" + tenDay
        $.ajax({
            type: "GET",
            url: "Add_RoomBlock",
            data: dataString,
            dataType: 'html',
            success: function (data) {
                $("#notice_new_block").html(data).show()
                setTimeout(function () {
                    $("#notice_new_block").fadeOut("slow", function () {
                        //$("#notice" + maLoai).remove();
                    });
                }, 2000);
                location.reload();
            }
        });
    });

    $(".delete_block").live("click", function () {
        var maHang = $(this).attr("id");
        var dataString = "maHang" + maHang;
        maHang = maHang.substr(1);
        $.ajax({
            type: "GET",
            url: "Delete_RoomBlock",
            data: dataString,
            dataType: 'html',
            success: function (data) {
                $("#notice_" + maHang).html(data).show();
                setTimeout(function () {
                    $("#notice_" + maHang).fadeOut("slow", function () {
                        //$("#notice" + maLoai).remove();
                    });
                }, 2000);
                location.reload();
            }
        });
    });

});